﻿#region Namespaces

using System.IO;

using Vibstudio.X4NET.IO;
using Vibstudio.X4NET.IO.Path;
using Vibstudio.X4NET.Test.Util;

using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace Vibstudio.X4NET.Test
{
    /// <summary>
    ///This is a test class for FilePathTests and is intended
    ///to contain all FilePathTests Unit Tests
    ///</summary>
    [TestClass]
    public class FilePathTests
    {
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        /// <summary>
        ///A test for FileName
        ///</summary>
        [TestMethod]
        public void Invoke()
        {
            const string FILE_NAME = "A01_E100_0.xml";

            FilePath target = new FilePath(IOHelper.ComposeSampleFilePath(FILE_NAME).Path);

            string fileName = target.FileName;
            string fileExtension = target.FileExtension;
            string fileNameWithoutExtension = target.FileNameWithoutExtension;
            string fileExtensionWithoutDot = target.FileExtensionWithoutDot;
            string path = target.Path;
            string pathWithoutFile = target.PathWithoutFile;
            string backupFileName = target.BackupFileName;

            Assert.IsNotNull(target);
        }

        [TestMethod]
        public void FilesAreEqual()
        {
            const string FILE1_NAME = "AppConfig1.xml";
            const string FILE2_NAME = "AppConfig2.xml";

            FilePath filePath1 = new FilePath(Path.Combine(IOHelper.SampleFileRootPath, FILE1_NAME));
            string filePath2 = Path.Combine(IOHelper.SampleFileRootPath, FILE2_NAME);

            bool areEqual = filePath1.AreEqual(filePath2);

            Assert.IsTrue(areEqual);
        }

        [TestMethod]
        public void PathTest()
        {
            const string SAMPLE_FILE_NAME_ORI = "SampleFileName.xml";
            const string SAMPLE_FILE_NAME_NEW = "SampleFileName.csv";

            FilePath filePathOri = IOHelper.ComposeSampleFilePath(SAMPLE_FILE_NAME_ORI);
            FilePath filePathNew = IOHelper.ComposeSampleFilePath(SAMPLE_FILE_NAME_NEW);

            Assert.AreEqual(filePathNew.Path, filePathOri.Path(FileType.Csv));
        }
    }
}